const { Transform } = require('stream');
const _ = require('lodash');
const utils = require('../../utils');


module.exports = function () {
  const stream = new Transform({ objectMode: true });
  const list = [];
  stream._transform = async function (chunk, encoding, callback) {
    list.push(chunk);
    callback();
  };
  stream._flush = function (callback) {
    stream.push(list)
    callback();
  };
  stream.on('finish', function () {
    utils.debug('arrayTransform [finish]');
  });

  return stream;
};